/*
 *  CMB Confidential
 *
 *  Copyright (C) 2018 China Merchants Bank Co., Ltd. All rights reserved.
 *
 *  No part of this file may be reproduced or transmitted in any form or by any
 *  means, electronic, mechanical, photocopying, recording, or otherwise, without
 *  prior written permission of China Merchants Bank Co., Ltd.
 */

package com.org.constant;


import com.org.util.JsonUtils;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 返回话术规范:
 * <p>
 * 一、命名规范
 * 1、命名应遵循以下规范：[类型]_[出现地]_[具体名称]
 * 1、所有异常情况分为逻辑错误以及抛出异常两类，命名分别以ERR以及EXP开头
 * 2、根据异常情况出现地分为:
 * CTL(controller)、SVC(service)、REP(reposity)、UTL(util)、FRM(form)、OTR(other)
 * <p>
 * 二、话术规范
 * 1、所有返回话术后需拼接标识，以方便排障
 * 2、标识规范如下：[RS-XXXX]，XXXX为三位数字
 *
 */
public enum ResponseEnum {

    ERR_CTL_FILE_PREVIEW_FAIL(Constant.CODE_1001, "系统维护中，请稍后重试[1001]"),

    ERR_UTILS_ENCRYPT_ERROR(Constant.CODE_1001, "签名失败[1002]"),

    NO_AGREEMENT_ERROR(Constant.CODE_1001, "系统维护中，请稍后重试[2001]")

    ;
    private String respCode;

    public String getRespMsg() {
        return respMsg;
    }

    private String respMsg;


    ResponseEnum(String respCode, String respMsg) {
        this.respCode = respCode;
        this.respMsg = respMsg;
    }

    public String getRespCode() {
        return respCode;
    }


    /**
     * 将返回结果转换成JsonString
     *
     * @return String
     */
    public String toJsonString() {
        return JsonUtils.objectToJsonString(toMap());
    }

    /**
     * 将返回结果转换成Map
     *
     * @return Map
     */
    public Map<String, Object> toMap() {
        LinkedHashMap<String, Object> respMap = new LinkedHashMap<>();
        respMap.put(Params.RESP_CODE, respCode);
        respMap.put(Params.RESP_MSG, respMsg);
        return respMap;
    }
}
